#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

int max_w[301][301][301];
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i ++) {
    int w, a, b;
    cin >> w >> a >> b;
    for (int j = a; j <= b; j ++) {
      max_w[a][b][j] = w;
    }
  }
  for (int l = n; l >= 1; l --) {
    for (int r = l; r <= n; r ++) {
      for (int k = l; k <= r; k ++) {
        if (k != l) { 
          max_w[l][r][k] = max(max_w[l][r][k], max_w[l+1][r][k]);
        }
        if (k != r) {
          max_w[l][r][k] = max(max_w[l][r][k], max_w[l][r-1][k]);
        }
      }
    }
  }
  vector<vector<int>> dp(n + 2, vector<int>(n + 2));
  for (int l = n; l >= 1; l --) {
    for (int r = l; r <= n; r ++) {
      for (int k = l; k <= r; k ++) {
        dp[l][r] = max(dp[l][r], dp[l][k - 1] + dp[k + 1][r] + max_w[l][r][k]);
      }
    }
  }
  cout << dp[1][n] << endl;
}